<template>
  <div id="bx">
    <div id="header">
      <div id="img1"></div>
      <div id="img2">
        <img
          height="29"
          src="../../assets/image/msg.png
      "
          alt=""
        />
      </div>
      <div id="pointlist">
        <div v-for="(item, index) in 14" :key="index" class="qq"></div>
        <div
          v-for="(item, index) in qqlist"
          :key="index"
          :class="{ qq: item === '1' }"
          class="bb"
        ></div>
      </div>
    </div>
    <div id="main">
      <div class="qiuq qiuq1"></div>
      <div class="qiuq qiuq2"></div>
      <img class="ii1" height="20" src="../../assets/image/kod.png" alt="" />
      <img class="ii2" height="20" src="../../assets/image/kod2.png" alt="" />
      <div class="harfclass">
        <img @click="toex" width="120.5" src="../../assets/image/harf.png" alt="" />
        <p>将于6月7号开课</p>
      </div>
      <div class="lesson">
        <div class="title">
          <img height="24.5" src="../../assets/image/itv.png" alt="" />
          <p>我的课表</p>
        </div>
        <div class="wrapper">
          <div class="lox">
            <div v-for="item in msg" :key="item.id" class="list">
              <div class="item">
                <div class="tito">
                  <div class="tieb"></div>
                  <div class="tieb2"></div>
                </div>
                <div class="tito2">
                  <div class="tieb"></div>
                  <div class="tieb2"></div>
                </div>
                <div class="listimg">
                  <img height="185" :src="item.src" alt="" />
                </div>
                <div class="pp">
                  <img class="arc" src="../../assets/image/arc.png" alt="" />
                  <p>{{ item.type + "p1" }}</p>
                </div>
                <div class="pi">
                  <img width="35" :src="item.peopleSrc" alt="" />
                </div>
                <p>{{ item.title }}</p>
                <i>{{ item.introduce }}</i>
                <div class="line"></div>
                <b>
                  <van-count-down :time="gettime(item.time)" format="DD天HH:mm:ss " />
                </b>
                <b>后开始上课</b>
                <div class="btn" @click="fn(item.id)"><p>进教室</p></div>
              </div>
            </div>
            <div class="emp"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getMyClassApi, getClassListApi } from "../../utils/api";
export default {
  data() {
    return {
      qqlist: ["0", "0", "0", "1", "1", "0", "1", "0", "0", "0", "0", "0", "1", "1"],
      time: "",
      timr: 1637699999808,
      msg: [],
    };
  },
  computed: {
    min() {
      return this.time.m < 10 ? "0" + this.time.m : this.time.m;
    },
  },
  created() {
    this.getdata();
  },

  methods: {
    toex() {
      this.$router.push("/exercise");
    },
    async getdata() {
      let token = localStorage.getItem("token");
      let resto = await getClassListApi();
      // console.log(resto.classList);
      const res = await getMyClassApi({
        token,
      });
      // console.log(res.results, resto.classList);

      if (res.status === 0) {
        for (var i = 0; i < res.results.length; i++) {
          for (var j = 0; j < resto.classList.length; j++)
            if (res.results[i] == resto.classList[j].id) {
              this.msg.push(resto.classList[j]);
            }
        }
      }

      // if (res.status === 0) {
      //
      // }
    },

    fn(id) {
      this.$router.push("/lesson/" + id);
    },

    gettime(timer) {
      let newtime = new Date().getTime();
      return timer - newtime;
    },
  },
};
</script>

<style lang="less" scoped>
#bx {
  overflow: auto;
  height: 571px;
}
#header {
  width: 100%;
  height: 136px;
  background-image: url(../../assets/image/slice.png);
  position: relative;
  #img1 {
    width: 114px;
    height: 46px;
    position: absolute;
    left: 39px;
    top: 62px;
    background: url(../../assets/image/list.png) no-repeat -13.32rem -0.333rem;
    background-size: 900%;
  }
  #img2 {
    position: absolute;
    left: 313px;
    top: 47px;
    width: 45px;
    height: 45px;
    background-color: rgb(55, 139, 237);
    border-radius: 22.5px;
    text-align: center;
    line-height: 58px;
  }
  #pointlist {
    position: absolute;
    left: 204px;
    .qq {
      width: 13px;
      height: 13px;
      border-radius: 6.5px;
      background-color: rgb(55, 139, 237);
      margin: 5px 0 0 10px;
      display: inline-block;
    }
    .bb {
      width: 13px;
      height: 13px;
      margin: 5px 0 0 10px;
      display: inline-block;
    }
  }
}
#main {
  position: relative;

  width: 100%;
  background-color: white;
  border-top-left-radius: 0.53333rem;
  border-top-right-radius: 0.53333rem;
  margin-top: -57px;
  .qiuq {
    width: 10px;
    height: 10px;
    border-radius: 5px;
    background-color: rgb(55, 139, 237);
    display: inline-block;
    position: absolute;
    top: 5px;
  }
  .qiuq1 {
    left: 20px;
  }
  .qiuq2 {
    right: 20px;
  }
  .ii1 {
    position: absolute;
    top: -10px;
    right: 25px;
  }
  .ii2 {
    position: absolute;
    top: -10px;
    left: 25px;
  }
  .harfclass {
    margin: 29px 0 0 21px;
    padding-top: 30px;
    p {
      margin: 7px 0 38.5px 15px;
      font-size: 11.5px;
    }
  }
  .lesson {
    margin-left: 15.5px;
    position: relative;
    .title {
      height: 24px;
      position: relative;
      margin-bottom: 13.5px;
      img {
        margin-left: 6.5px;
      }
      p {
        position: absolute;
        font-size: 17px;
        top: 5px;
        left: 35px;
        font-weight: 600;
      }
    }
    .wrapper {
      overflow: hidden;
      height: 100%;
    }
    .lox {
      display: inline-flex;
      flex-flow: column;
    }
    .list {
      padding-top: 15px;
      position: relative;
      .item {
        height: 324px;
        width: 344px;
        border-radius: 20px;
        border: 1px solid lightgray;
        padding: 14px 13px 11px 11.5px;
        position: relative;
        margin-bottom: 42px;
        box-shadow: 2px -2px 2px lightgray;
        .listimg {
          width: 320px;
          height: 185px;
          border-radius: 8px;
          overflow: hidden;
          border: 1px solid gray;
        }
        .pp {
          background-color: rgb(255, 231, 0);
          width: 80px;
          height: 16px;
          position: absolute;
          left: 5px;
          top: 25px;
          border-top-right-radius: 8px;
          border-top-left-radius: 8px;
          border-bottom-right-radius: 8px;
          .arc {
            position: absolute;
            left: 0;
            top: 16px;
            width: 10px;
          }
          p {
            font-size: 12px;
            margin: 2px;
            text-align: center;
          }
        }
        .pi {
          width: 32px;
          height: 32px;
          // background-color: yellow;
          position: absolute;
          overflow: hidden;
          left: 294px;
          top: 22px;
          border-radius: 16px;
          img {
            margin: 0;
          }
        }
        p {
          margin-top: 10px;
          font-size: 14px;
          font-weight: 600;
          margin-left: 3px;
        }
        i {
          margin-top: 10px;
          display: inline-block;
          font-size: 13.5px;
          margin-left: 3px;
          width: 200px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .line {
          border: dashed 1px gray;
          margin-top: 15px;
          margin-left: 3px;
        }
        b {
          display: inline-block;
          margin-left: 3px;
          margin-top: 17px;
          font-size: 13.5px;
          color: rgb(55, 139, 237);
        }
        .van-count-down {
          color: rgb(55, 139, 237);
        }
        .btn {
          position: absolute;
          bottom: 6px;
          right: 14.5px;
          background-color: rgb(55, 139, 237);
          height: 38px;

          border-radius: 19px;
          width: 94.5px;
          p {
            margin: 10px 19px 11px 22px;
            font-size: 17px;
            text-align: center;
            color: white;
          }
        }
      }
    }
    .emp {
      height: 50px;
      width: 1px;
    }
    .tito {
      // background-color: turquoise;
      position: absolute;
      left: 16px;
      top: -10px;
      width: 100%;
      height: 17.5px;
      .tieb {
        width: 6px;
        height: 17.5px;
        border-radius: 3px;
        background-color: white;
        border: 1px solid black;
        position: absolute;
      }
      .tieb2 {
        width: 6px;
        height: 17.5px;
        border-radius: 3px;
        background-color: white;
        border: 1px solid black;
        position: absolute;
        left: 15px;
      }
    }
    .tito2 {
      // background-color: turquoise;
      position: absolute;
      left: 300px;
      top: -10px;
      width: 100%;
      height: 17.5px;
      .tieb {
        width: 6px;
        height: 17.5px;
        border-radius: 3px;
        background-color: white;
        border: 1px solid black;
        position: absolute;
      }
      .tieb2 {
        width: 6px;
        height: 17.5px;
        border-radius: 3px;
        background-color: white;
        position: absolute;
        border: 1px solid black;
        left: 15px;
      }
    }
  }
}
</style>
